package Util::CommentedItem::CommentedItem;
use Moose;
use namespace::autoclean;

has 'schema' => (
	is => 'rw',
	required => 1,
	isa => 'DBIx::Class::Schema',
);

sub add_to_comments{
	my ($self, $comm_id, $user_id, $comment) = @_;
	my $comm_item = $self->schema->resultset('CommentedItem')->find($comm_id);
        $comm_item->add_to_comments({
		user_id=>$user_id, 
		content=>$comment}
	);

}

sub create{
	my ($self, $comm_type_id) = @_;
	return $self->schema->resultset('CommentedItem')->create({comm_item_type_id => $comm_type_id});
}

sub find {
	my ($self, $comm_id) = @_;
	return $self->schema->resultset('CommentedItem')->find($comm_id);	
}

__PACKAGE__->meta->make_immutable;

1;
